package com.faner.fast.file.extension;

import com.faner.fast.file.Uploader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

/**
 * 文件上传配置类
 *
 * @author Juzi@TaleLin
 */
@Configuration
public class UploaderConfiguration {

    @Value("${file.upload:local}")
    private String uploadAddress;
    /**
     * @return 本地文件上传实现类
     */
    @Bean
    @Order
    @ConditionalOnMissingBean
    public Uploader uploader(){
        switch (this.uploadAddress) {
            case "local":
                return new LocalUploader();
            case "qiniuyun":
                return new QiniuUploader();
            case "oss":
                return new OssUploader();
            default:
                break;
        }
        return null;
    }


}
